import { defineConfig, loadEnv } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'

// https://vite.dev/config/

export default ({mode}:{mode:any})=>{
  const env = loadEnv(mode, process.cwd());
  console.log('++++++++++++++++++++++++++++', env)

  return defineConfig({
    base: './',
    optimizeDeps: { exclude: ["fsevents"] },
    plugins: [
      vue(),
    ],
    css: {
      preprocessorOptions: {
        scss: {
          // additionalData: '@import "./src/assets/styles/mixin.scss";',
        },
      },
    },
    server: {
      host: '0.0.0.0',
      proxy: {
        '/api': {
          // target: 'https://glan.geely-test.com',
          target: 'http://192.168.0.178:9001',
          changeOrigin: false,
          rewrite: (path:any) => path.replace(/^\/api/, ''), // 去掉请求路径中的 '/admin'
        },
      },
    },
    resolve: {
      alias: {
        '@': path.resolve(__dirname, './src'),
      },
    },
  })
}